<template>
  <Card class="cpyszjy-optional-editor" style="height:900px">
    <div style="width:1200px;margin:50px auto">
      <Row type="flex" align="middle">
        <Col span="2">产品大类:</Col>
        <Col span="14">
        <Input placeholder="请输入" v-model="productTypeName" disabled style="width: 200px"></Input>
        </Col>
        <Col span="2">产品:</Col>
        <Col span="6">
        <Input placeholder="请输入" v-model="product" disabled style="width: 200px"></Input>
        </Col>
      </Row>
      <br>
      <Row type="flex" align="middle">
        <Col span="2">资金源:</Col>
        <Col span="14">
        <Input placeholder="请输入" v-model="fund" disabled style="width: 200px"></Input>
        </Col>
        <Col span="2">优先级:</Col>
        <Col span="6">
        <Input placeholder="请输入" v-model="prior" :disabled="allMark" style="width: 200px"></Input>
        </Col>
      </Row>
      <br>
      <Row type="flex" align="middle">
        <Col span="2">状态:</Col>
        <Col span="14">
        <Select v-model="status" style="width:200px" :disabled="allMark">
          <Option v-for="item in statusList" :value="item.value" :key="item.value">{{ item.label }}</Option>
        </Select>
        </Col>
        <Col span="2"></Col>
        <Col span="6">
        </Col>
      </Row>
      <br>
      <Row type="flex" align="middle" style="margin-top:50px;">
        <Col span="2">最后更新时间:</Col>
        <Col span="14"> {{updatedDate}}
        </Col>
        <Col span="2">最后更新用户:</Col>
        <Col span="6">{{updatedBy}}
        </Col>
      </Row>
      <Row v-if="type == '2'" type="flex" align="middle" style="margin-top:50px;">
        <Col span="6"></Col>
        <Col span="6" style="text-align:center">
        <Button type="primary" @click="conf" size="small">确认</Button>
        </Col>
        <Col span="6">
        <Button type="primary" @click="handleGoBack" size="small">返回</Button>
        </Col>
        <Col span="6">

        </Col>
      </Row>
      <Row v-if="type == '1'" type="flex" align="middle" style="margin-top:50px;">
        <Col span="6"></Col>
        <Col span="6" style="text-align:center">
        <Button type="primary" @click="edit" size="small">编辑</Button>
        </Col>
        <Col span="6">
        <Button type="primary" @click="handleGoBack" size="small">返回</Button>
        </Col>
        <Col span="6">

        </Col>
      </Row>
    </div>
  </Card>
</template>
<script>
export default {
  data () {
    return {
      allMark: false,
      productTypeName: '',
      product: '',
      fund: '',
      prior: '',
      status: '',
      statusList: [
        {
          value: '1',
          label: '异常'
        },
        {
          value: '0',
          label: '正常'
        }
      ],
      type: '',
      updatedBy: '',
      updatedDate: ''
    }
  },
  created () {
    var vm = this
    this.$ajax = this.$util.ajax(this.$appContext.marvels_core_product)
    var param = JSON.parse(vm.$route.query.param)
    vm.productTypeName = param.productTypeName
    vm.product = param.productName
    vm.fund = param.fundName
    vm.updatedBy = param.updatedBy
    vm.updatedDate = param.updatedDate
    vm.prior = param.level + ''
    if (param.status === '正常') {
      vm.status = '0'
    } else {
      vm.status = '1'
    }
    vm.type = vm.$route.query.type
    if (vm.type === '1') {
      vm.allMark = true
    }
  },
  mounted () { },
  methods: {
    handleRouterGo () {
      this.$router.push('cpyszjyiview')
    },
    conf () {
      var vm = this
      var param = JSON.parse(vm.$route.query.param)
      var r = /^\+?[1-9][0-9]*$/
      if (!r.test(vm.prior.trim())) {
        this.$Message.warning('优先级格式不正确')
        return
      }
      var params = {
        id: param.id,
        level: vm.prior,
        status: vm.status
      }
      this.$ajax.post(this.$appContext.marvels_core_product + 'product/mcpt/service/removeProductMappingFund', params)
        .then(re => {
          if (re.data.code === 'success') {
            this.$router.push('productFund')
          }
        })
        .catch(er => { })
    },
    edit () {
      var vm = this
      vm.type = '2'
      vm.allMark = false
    },
    handleGoBack () {
      this.$router.push('productFund')
    }
  },
  props: {},
  watch: {
    $route (val) { }
  }
}
</script>

<style lang="less">
.cpyszjy-optional-editor {
}
</style>
